<template>
  <div @click="$emit('show-play-bar')" class="player-header">
    <div class="back"><i class="iconfont icon-gengduo2"></i></div>
    <div class="currentMusic">
      <h4>{{ current.name }}</h4>
      <p>
        <span v-for="(artists, index) in current.ar" :key="artists.id">
          <template v-if="index">/</template> {{ artists.name }}
        </span>
      </p>
    </div>
    <div class="share">
      <i class="iconfont icon-fenxiang2"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: ["currentMusic","current"],
  computed: {
    currentSongName() {
      if (this.currentMusic.name) {
        return this.currentMusic.name;
      } else if (this.currentMusic.al.name) {
        return this.currentMusic.al.name;
      } else {
        return "获取出错";
      }
    },
    currentName() {
      if (this.currentMusic.ar) {
        return this.currentMusic.ar;
      } else if (this.currentMusic.song.artists) {
        return this.currentMusic.song.artists;
      }  else if (this.currentMusic.artists) {
        return this.currentMusic.artists;
      }else {
        return "获取出错";
      }
     
    },
  },
};
</script>

<style scoped lang="less">
.player-header {
  height: 58px;
  // padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .back,
  .share {
    display: grid;
    place-content: center;
    .iconfont {
      color: white;
      font-size: 20px;
    }
  }
  .back{
    flex-basis: 40px;
  }
  .share {
    width: 40px;
    flex-basis: 40px;
    .iconfont {
      color: white;
      font-size: 24px;
    }
  }
  .currentMusic {
    text-align: center;
    width: 80%;
    padding: 0 15px;
    box-sizing: border-box;
      overflow: hidden;
    h4,
    p {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    h4 {
      font-size: 14px;
      font-weight: 600;
      color: white;
    }
    p {
      font-size: 12px;
      color: #ccc;
    }
  }
}
</style>